﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.Mvc;

namespace GestionCompte.Entity
{
    public class CategoryEntity
    {
        public int Id { get; set; }
        public string Name {get; set;}
        public bool IsOneShot { get; set; }
        public IList<OperationEntity> Operations { get; set; }

        public CategoryEntity()
        { throw new NotImplementedException("The default constructor is not authorized in this context."); }

        public CategoryEntity(int id, string name,bool isOneShot, ICollection<EntityAccess.OperationEntity> operations)
        {
            if (id <= 0 || name == null)
                throw new ArgumentException("One or more arguments is/are null or have an incorrect value for the CategoryEntity Constructor");

            this.Id = id;
            this.Name = name;
            this.IsOneShot = isOneShot;
            this.Operations = (IList<OperationEntity>) operations.Select(x => new OperationEntity(x));
        }
    }
}
